﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using HumanManagement.BusinessObjects;
using HumanManagement.DataAccess;

namespace HumanManagement.BusinessLogic
{
	public class DocumentBL
	{

		#region ***** Init Methods ***** 
		DocumentDA objDocumentDA;
		public DocumentBL()
		{
			objDocumentDA = new DocumentDA();
		}
		#endregion

		#region ***** Get Methods ***** 
		/// <summary>
		/// Get Document by id
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns>Document</returns>
		public Document GetByID(int id)
		{
			return objDocumentDA.GetByID(id);
		}

		/// <summary>
		/// Get all of Document
		/// </summary>
		/// <returns>List<<Document>></returns>
		public List<Document> GetList()
		{
			string cacheName = "lstDocument";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objDocumentDA.GetList(), "Document");
			}
			return (List<Document>) ServerCache.Get(cacheName);
		}

		/// <summary>
		/// Get DataSet of Document
		/// </summary>
		/// <returns>DataSet</returns>
		public DataSet GetDataSet()
		{
			string cacheName = "dsDocument";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objDocumentDA.GetDataSet(), "Document");
			}
			return (DataSet) ServerCache.Get(cacheName);
		}


		/// <summary>
		/// Get all of Document paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>List<<Document>></returns>
		public List<Document> GetListPaged(int recperpage, int pageindex)
		{
			return objDocumentDA.GetListPaged(recperpage, pageindex);
		}

		/// <summary>
		/// Get DataSet of Document paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>DataSet</returns>
		public DataSet GetDataSetPaged(int recperpage, int pageindex)
		{
			return objDocumentDA.GetDataSetPaged(recperpage, pageindex);
		}





		#endregion

		#region ***** Add Update Delete Methods ***** 
		/// <summary>
		/// Add a new Document within Document database table
		/// </summary>
		/// <param name="obj_document">Document</param>
		/// <returns>key of table</returns>
		public int Add(Document obj_document)
		{
			ServerCache.Remove("Document", true);
			return objDocumentDA.Add(obj_document);
		}

		/// <summary>
		/// updates the specified Document
		/// </summary>
		/// <param name="obj_document">Document</param>
		/// <returns></returns>
		public void Update(Document obj_document)
		{
			ServerCache.Remove("Document", true);
			objDocumentDA.Update(obj_document);
		}

		/// <summary>
		/// Delete the specified Document
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns></returns>
		public void Delete(int id)
		{
			ServerCache.Remove("Document", true);
			objDocumentDA.Delete(id);
		}
		#endregion
	}
}
